home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 6 code / TCP / NewsWatcher / NW Source / Source / about.c next >
Encoding:
C/C++ Source or Header  |  1995-05-18  |  4.0 KB  |  168 lines  |  [TEXT/MMCC]

  1. /*----------------------------------------------------------------------------
  2.  
  3.     about.c
  4.  
  5.     This module presents the about box.
  6.     
  7.     Copyright © 1994-1995, Northwestern University.
  8.  
  9. ----------------------------------------------------------------------------*/
  10.  
  11. #include <stdio.h>
  12.  
  13. #include "glob.h"
  14. #include "about.h"
  15. #include "text.h"
  16. #include "drawutil.h"
  17. #include "strutil.h"
  18. #include "windutil.h"
  19. #include "resutil.h"
  20. #include "help.h"
  21.  
  22.  
  23.  
  24. #define kAboutText             128        /* resource id of about box text 'TEXT' resource */
  25.  
  26. #define kEggID                129        /* resource id of Easter egg 'STR#' resource */
  27.  
  28. #define kBigIconPictColor    128        /* resource id of big icon color picture */
  29. #define kBigIconPictBW        129        /* resource id of big icon B&W picture */
  30. #define kLogoPictColor        130     /* resource id of logo color picture */
  31. #define kLogoPictBW            131     /* resource id of logo B&W picture */
  32.  
  33.  
  34.  
  35. static short gDrawEasterEgg = 0;
  36.  
  37.  
  38.  
  39. /*----------------------------------------------------------------------------
  40.     DrawPanel.
  41.     
  42.     Draw the panel area.
  43.     
  44.     Entry:    wind = pointer to about window.
  45. ----------------------------------------------------------------------------*/
  46.  
  47. static void DrawPanel (WindowPtr wind)
  48. {
  49.     Rect r;
  50.     CStr255 versStr;
  51.     Str255 str;
  52.     CStr255 fmt;
  53.     TextStyle savedStyle;
  54.     OSErr err = noErr;
  55.     Str255 egg;
  56.     
  57.     GetPortTextStyle(&savedStyle);
  58.     SetRect(&r, 50, 10, 134, 85);
  59.     DrawColorPict(kBigIconPictColor, kBigIconPictBW, &r);
  60.     SetRect(&r, 180, 17, 390, 56);
  61.     DrawColorPict(kLogoPictColor, kLogoPictBW, &r);
  62.  
  63.     err = GetVersionString((StringPtr)versStr);
  64.     p2cstr((StringPtr)versStr);
  65.     if (err != noErr) goto exit;
  66.     GetCString(kStrVersion, fmt);
  67.     sprintf((char*)str, fmt, versStr);
  68.     c2pstr((char*)str);
  69.     MoveTo(183, 70);
  70.     TextFont(systemFont);
  71.     TextSize(12);
  72.     DrawString(str);
  73.     if (gDrawEasterEgg > 0) {
  74.         MoveTo(183, 88);
  75.         TextFont(applFont);
  76.         TextSize(9);
  77.         TextFace(bold | italic);
  78.         GetIndString(egg, kEggID, gDrawEasterEgg);
  79.         if (*egg == 0) {
  80.             gDrawEasterEgg = 0;
  81.         } else {
  82.             DrawString(egg);
  83.         }
  84.     }
  85.     
  86. exit:
  87.  
  88.     SetPortTextStyle(&savedStyle);
  89. }
  90.  
  91.  
  92.  
  93. /*----------------------------------------------------------------------------
  94.     DoAboutNewsWatcher
  95.     
  96.     Present the about box.
  97.     
  98.     Exit:    function result = error code.
  99. ----------------------------------------------------------------------------*/
  100.  
  101. OSErr DoAboutNewsWatcher (void)
  102. {
  103.     Handle text;
  104.     Str255 title;
  105.     OSErr err = noErr;
  106.     WindowPtr wind;
  107.     
  108.     gDrawEasterEgg = 0;
  109.     GetPString(kStrAboutWindTitle, title);
  110.     if (CheckTextWindowAlreadyOpen(title)) return noErr;
  111.     err = MyGet1Resource('TEXT', kAboutText, &text);
  112.     if (err != noErr) return err;
  113.     err = MakeNewTextWindow(title, 100, DrawPanel, text, &wind);
  114.     MyReleaseResource(text);
  115.     return err;
  116. }
  117.  
  118.  
  119.  
  120. /*----------------------------------------------------------------------------
  121.     CheckAboutWindowEasterEgg
  122.     
  123.     Check for mouse down on big icon, display Easter egg.
  124.     
  125.     Entry:    wind = pointer to text window.
  126.             where = mouse down location, local coords.
  127.             modifiers = keyboard modifiers.
  128. ----------------------------------------------------------------------------*/
  129.  
  130. void CheckAboutWindowEasterEgg (WindowPtr wind, Point where, short modifiers)
  131. {
  132.     Rect r;
  133.     Str255 title, windTitle;
  134.     
  135.     if ((modifiers & optionKey) == 0) return;
  136.     GetPString(kStrAboutWindTitle, title);
  137.     GetWTitle(wind, windTitle);
  138.     if (!EqualString(title, windTitle, false, false)) return;
  139.     SetRect(&r, 50, 10, 134, 85);
  140.     if (!PtInRect(where, &r)) return;
  141.     gDrawEasterEgg++;
  142.     SetRect(&r, 180, 76, wind->portRect.right, 93);
  143.     InvalRect(&r);
  144. }
  145.  
  146.  
  147.  
  148. /*----------------------------------------------------------------------------
  149.     DoAboutWindowIconHelpBalloon 
  150.     
  151.     Handle the help ballown for the big icon in the about window.
  152.             
  153.     Entry:    wind = pointer to text window.
  154.             where = current mouse location in local coordinates.
  155. ----------------------------------------------------------------------------*/
  156.  
  157.  
  158. void DoAboutWindowIconHelpBalloon (WindowPtr wind, Point where)
  159. {
  160.     Rect r;
  161.     Point tip;
  162.     
  163.     SetRect(&r, 50, 10, 134, 85);
  164.     if (!PtInRect(where, &r)) return;
  165.     SetPt(&tip, 120, 77);
  166.     ShowHelpBalloon(tip, &r, 8);
  167. }
  168.